<?php
App::uses('Component', 'Controller');
App::uses('CakeEmail', 'Network/Email');

class BagabEmailComponent extends Component{
	
	public function sendCredentials($emailaddress, $username, $password)
	{
		$email = new CakeEmail('gmail');
		$email->to($emailaddress);
		$email->subject('BagaB - Vos Identifiants');
		$email->template('forgotten_credentials','bagab');
		$email->emailFormat('text');
		$email->layout('bagab');
		$email->viewVars(array
			('username' => $username,
			 'password' => $password
			)
		);
		$email->send();			
	}
	
	public function sendPassword($emailaddress, $password)
	{
		$email = new CakeEmail('gmail');
		$email->to($emailaddress);
		$email->subject('BagaB - Votre Mot de Passe');
		$email->template('forgotten_password','bagab');
		$email->emailFormat('text');
		$email->layout('bagab');
		$email->viewVars(array
			(
			'password' => $password
			)
		);
		$email->send();
	}
	
	public function bookingConfirmed($order)
	{
		$email = new CakeEmail('gmail');
		$email->to($order['Order']['email']);
		$email->subject('BagaB - Votre reservation est confirmee');
		$email->template('booking_confirmed','bagab');
		$email->emailFormat('html');
		$email->viewVars(array
			(
			'order' => $order
			)
		);
		$email->send();
	}
	
	public function bookingNotification($order)
	{
		$email = new CakeEmail('gmail');
		$email->to('nicolas.fenwick@gmail.com');
		$email->subject('BagaB - Une nouvelle reservation!!');
		$email->template('booking_notification','bagab');
		$email->emailFormat('html');
		$email->viewVars(array
			(
			'order' => $order
			)
		);
		$email->send();
	}
}